import {
	guid
} from "./common.js"

/**
 * 添加graphicLayer
 * @param view              {view}                  地图对象
 * @param layerId           {string}                图层id
 * @param graphicList       {Graphic | Graphic[]}   Graphic对象或者Graphic对象集合
 * @returns                 {GraphicLayer}          GraphicLayer实例
 */
export const addGraphicLayer = ({
	view = null,
	layerId = guid(),
	graphicList = null,
	Arcgis: {
		GraphicsLayer
	}
}) => {
	if (!view) return

	let graphicLayer = new GraphicsLayer({
		id: layerId
	});

	graphicList && graphicLayer.addMany(graphicList)

	view.map.add(graphicLayer);
	return graphicLayer;
};